#include <iostream>
#include <zlib/net/I_UnixNetProcessor.h>
#include <unistd.h>

using namespace std;

class TestConnect : public Continuation
{
public:
	TestConnect()
	{
		SET_HANDLER(&TestConnect::mainEvent);
	}

	int mainEvent(int event, void *data)
	{
		if(event == NET_EVENT_CONNECT)
		{
			cout << "connect sucess" << endl;
		}else{
			cout << "connect faild" << endl;
		}

		UnixNetVConnect *vc = (UnixNetVConnect *)data;
		char buff[] = "abcdefghi";
		int ret = write(vc->fd, buff, strlen(buff));
		cout << ret << endl;
	}
};

int main()
{
	TestConnect tc;
	tc.mutex = new_ProxyMutex();
	IpEntry entry;
	entry.init(AF_INET, "127.0.0.1", 8888);
	NetOptions opt;
	opt.fd_blocking = true;
	opt.fd_blocking_connect = true;
	eventProcessor.start(1);
	netProcessor.start(0);
	netProcessor.connect_re(&tc, entry, opt);

	sleep(10000);

}
